<?php
class AboutLeftNav extends CWidget {
	const CATEGORY_1 = 33;
	const CATEGORY_2 = 63;
	public $categories;
	public $post;
	public $active;

	public function init() {
		if($this->getController()->getId() == 'about' && $this->getController()->getAction()->getId() == 'index' && $this->post !== null) {
			$this->active = 'post'.$this->post->postId;
		} else if($this->getController()->getId() == 'psychologist' && $this->getController()->getAction()->getId() == 'list') {
			$this->active = 'psychologistsList';
		} else {
			$this->active = '';
		}

		$this->categories = array();
		$categoryIds = $this->_getCategoryIds();
		foreach($categoryIds as $categoryId) {
			$this->categories[] = TermsTaxonomy::model()->category()->with('posts')->findByPk($categoryId);
		}
	}

	public function run() {
		$this->renderContent();
	}

	public function renderContent($return = false) {
		return $this->render('about-left-nav', array(
			'categories' => $this->categories,
			'post' => $this->post,
			'active' => $this->active
		), $return);
	}

	protected function _getCategoryIds() {
		return array(self::CATEGORY_1, self::CATEGORY_2);
	}
}